package com.albb.util;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @Title:
 * @BelongProjecet Day59
 * @BelongPackage com.albb.util
 * @Description:
 * @Copyright 研发一部
 * @Author: 马召茹
 * @Date: 2024/5/9 8:38
 * @Version V1.0
 */
@Data
public class R implements Serializable {
    private Integer code;

    private String message;

    private boolean flag;

    private HashMap<String,Object> map=new HashMap<>(16);

    public R (){};

    public static R ok(){
        R r = new R();
        r.setMessage("成功");
        r.setFlag(true);
        r.setCode(2000);
        return r;
    }

    public static R error(){
        R r = new R();
        r.setMessage("失败");
        r.setFlag(false);
        r.setCode(2001);
        return r;
    }

    public R message(String message){
        this.message=message;
        return this;
    }
    public R code(Integer code){
        this.code=code;
        return this;
    }
    public R flag(boolean flag){
        this.flag=flag;
        return this;
    }
    public R map(String key,Object value){
        this.map.put(key,value);
        return this;
    }
    public R map(HashMap<String,Object> map){
        this.map.putAll(map);
        return this;
    }
}

